package com.atguigu.bigdata.gmall.realtime.function;

import com.atguigu.bigdata.gmall.realtime.util.AtguiguUtil;
import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;

import java.util.List;

/**
 * @Author lzc
 * @Date 2022/10/14 10:03
 */
@FunctionHint(output = @DataTypeHint("row<keyword string>"))
public class KWSplit extends TableFunction<Row> {
    public void eval(String kw){
        List<String> words = AtguiguUtil.ikSplit(kw);
        // 每执行一次, 相当于得到一行数据
        for (String word : words) {
            collect(Row.of(word));
            
        }
       
    }
}
